package com.run.merchant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.run.common.annotation.Log;
import com.run.common.core.controller.BaseController;
import com.run.common.core.domain.AjaxResult;
import com.run.common.enums.BusinessType;
import com.run.merchant.domain.RunLevelInfo;
import com.run.merchant.service.IRunLevelInfoService;
import com.run.common.utils.poi.ExcelUtil;
import com.run.common.core.page.TableDataInfo;

/**
 * 代取员提升等级申请信息Controller
 * 
 * @author run
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/merchant/infolevel")
public class RunLevelInfoController extends BaseController
{
    @Autowired
    private IRunLevelInfoService runLevelInfoService;

    /**
     * 查询代取员提升等级申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:list')")
    @GetMapping("/list")
    public TableDataInfo list(RunLevelInfo runLevelInfo)
    {
        startPage();
        List<RunLevelInfo> list = runLevelInfoService.selectRunLevelInfoList(runLevelInfo);
        return getDataTable(list);
    }

    /**
     * 导出代取员提升等级申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:export')")
    @Log(title = "代取员提升等级申请信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RunLevelInfo runLevelInfo)
    {
        List<RunLevelInfo> list = runLevelInfoService.selectRunLevelInfoList(runLevelInfo);
        ExcelUtil<RunLevelInfo> util = new ExcelUtil<RunLevelInfo>(RunLevelInfo.class);
        util.exportExcel(response, list, "代取员提升等级申请信息数据");
    }

    /**
     * 获取代取员提升等级申请信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:query')")
    @GetMapping(value = "/{levelId}")
    public AjaxResult getInfo(@PathVariable("levelId") Long levelId)
    {
        return success(runLevelInfoService.selectRunLevelInfoByLevelId(levelId));
    }

    /**
     * 新增代取员提升等级申请信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:add')")
    @Log(title = "代取员提升等级申请信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RunLevelInfo runLevelInfo)
    {
        return toAjax(runLevelInfoService.insertRunLevelInfo(runLevelInfo));
    }

    /**
     * 修改代取员提升等级申请信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:edit')")
    @Log(title = "代取员提升等级申请信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RunLevelInfo runLevelInfo)
    {
        return toAjax(runLevelInfoService.updateRunLevelInfo(runLevelInfo));
    }

    /**
     * 删除代取员提升等级申请信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infolevel:remove')")
    @Log(title = "代取员提升等级申请信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{levelIds}")
    public AjaxResult remove(@PathVariable Long[] levelIds)
    {
        return toAjax(runLevelInfoService.deleteRunLevelInfoByLevelIds(levelIds));
    }
}
